/*
 * Copyright 2008-2012 Centro Andaluz de Innovación y Tecnologías de la
 * Información y las Comunicaciones (CITIC). All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 *
 * Please contact CITIC - Edificio CITIC, C/ Marie Curie, 6 Parque
 * Tecnológico de Andalucía 29590 - Campanillas, Málaga, Spain
 * or visit www.citic.es, if you need additional information or
 * have any questions.
 */

package es.citic.puedes.youtube.test.unit;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import es.citic.puedes.youtube.IYouTubeManager;
import es.citic.puedes.youtube.YouTubeAuthException;
import es.citic.puedes.youtube.YouTubeException;
import es.citic.puedes.youtube.bbdd.YouTubeDataBase;
import es.citic.puedes.youtube.impl.YouTubeManagerImpl;
import es.citic.puedes.youtube.model.Category;
import es.citic.puedes.youtube.model.OrderBy;
import es.citic.puedes.youtube.model.StandarVideos;
import es.citic.puedes.youtube.model.YouTubeContact;
import es.citic.puedes.youtube.model.YouTubeResult;
import es.citic.puedes.youtube.model.YouTubeType;
import es.citic.puedes.youtube.model.YouTubeUser;
import es.citic.puedes.youtube.model.YouTubeVideo;
import es.citic.puedes.youtube.model.YouTubeVideo.State;
import es.citic.puedes.youtube.model.YouTubeVideoMinimal;

public class PU_YouTubeManager_1 {

	private YouTubeDataBase dataBase;
	private IYouTubeManager youtube;

	@Before
	public void setUp() throws Throwable {
		// HSQLDB in memory config
		Map<String, String> properties = new HashMap<String, String>();
		properties.put(PersistenceUnitProperties.JDBC_DRIVER,
				"org.hsqldb.jdbcDriver");
		properties.put(PersistenceUnitProperties.JDBC_URL,
				"jdbc:hsqldb:mem:test");
		properties.put(PersistenceUnitProperties.JDBC_USER, "SA");
		properties.put(PersistenceUnitProperties.JDBC_PASSWORD, "");
		properties.put(PersistenceUnitProperties.DDL_GENERATION,
				"drop-and-create-tables");
		// properties.put("eclipselink.logging.level", "FINE");

		dataBase = new YouTubeDataBase("YouTubeManager_pu", properties);
		youtube = new YouTubeManagerImpl("META-INF/config.xml", dataBase);
	}

	@After
	public void tearDown() throws Exception {
		dataBase.cleanEntityManager();
	}

	@Test
	public void test_PU_01() {
		/*
		 * registreUser(Integer userId, String userName, String password)
		 */
		try {
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.registreUser(null, youtubeName, youtubePass);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_02() {
		/*
		 * registreUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, null, youtubePass);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_03() {
		/*
		 * registreUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			youtube.registreUser(userId, youtubeName, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_04() {
		/*
		 * registreUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubePass = "citiccitic";
			youtube.registreUser(userId, "", youtubePass);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_05() {
		/*
		 * registreUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			youtube.registreUser(userId, youtubeName, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_06() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * registreUser(Integer userId, String userName, String password)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);
	}

	@Test
	public void test_PU_07() {
		/*
		 * deleteUser(Integer userId)
		 */
		try {
			youtube.deleteUser(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_08() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteUser(Integer userId)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);
		youtube.deleteUser(userId);
	}

	@Test
	public void test_PU_09() {
		/*
		 * changeUser(Integer userId, String userName, String password)
		 */
		try {
			String youtubeName = "you2bectc";
			String youtubePass = "citiccitic";
			youtube.changeUser(null, youtubeName, youtubePass);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_10() {
		/*
		 * changeUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubePass = "citiccitic";
			youtube.changeUser(userId, null, youtubePass);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_11() {
		/*
		 * changeUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			youtube.changeUser(userId, youtubeName, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_12() {
		/*
		 * changeUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubePass = "citiccitic";
			youtube.changeUser(userId, "", youtubePass);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_13() {
		/*
		 * changeUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 1;
			String youtubeName = "you2bectc";
			youtube.changeUser(userId, youtubeName, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_14() {
		/*
		 * changeUser(Integer userId, String userName, String password)
		 */
		try {
			int userId = 999;
			String youtubeName = "you2bectc2";
			String youtubePass = "citiccitic2";
			youtube.changeUser(userId, youtubeName, youtubePass);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_15() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * changeUser(Integer userId, String userName, String password)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		try {
			youtube.changeUser(userId, youtubeName + "2", youtubePass + "2");
		} catch (Exception e) {
			// Se necesita que el usuario haya cambiado previamente su nombre
			// y/o contrase�a en el servicio de youtube
		}
	}

	@Test
	public void test_PU_16() {
		/*
		 * YouTubeUser getUserProfile(Integer userId)
		 */
		try {
			youtube.getUserProfile(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_17() {
		/*
		 * YouTubeUser getUserProfile(Integer userId)
		 */
		try {
			int userId = 999;
			youtube.getUserProfile(userId);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_18() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * YouTubeUser getUserProfile(Integer userId)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);
		YouTubeUser user = youtube.getUserProfile(userId);
		assertNotNull(user);
	}

	@Test
	public void test_PU_19() {
		/*
		 * void insertVideo(YouTubeUser user, YouTubeVideo video, String
		 * videoPath)
		 */
		try {
			YouTubeVideo video = new YouTubeVideo();
			String videoPath = "videopath";
			youtube.insertVideo(null, video, videoPath);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_20() {
		/*
		 * void insertVideo(YouTubeUser user, YouTubeVideo video, String
		 * videoPath)
		 */
		try {
			YouTubeUser user = new YouTubeUser();
			String videoPath = "videopath";
			youtube.insertVideo(user, null, videoPath);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_21() {
		/*
		 * void insertVideo(YouTubeUser user, YouTubeVideo video, String
		 * videoPath)
		 */
		try {
			YouTubeUser user = new YouTubeUser();
			YouTubeVideo video = new YouTubeVideo();
			youtube.insertVideo(user, video, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_22() {
		/*
		 * void insertVideo(YouTubeUser user, YouTubeVideo video, String
		 * videoPath)
		 */
		try {
			YouTubeUser user = new YouTubeUser();
			YouTubeVideo video = new YouTubeVideo();
			youtube.insertVideo(user, video, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_23() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * void insertVideo(YouTubeUser user, YouTubeVideo video, String
		 * videoPath)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		// test for uploading a video
		YouTubeVideo videoToUpload = new YouTubeVideo();

		List<String> keyWordsTestList = new ArrayList<String>();
		keyWordsTestList.add("tortuga");
		keyWordsTestList.add("mascota");
		keyWordsTestList.add("animal");

		List<Category> categories = new ArrayList<Category>();
		categories.add(Category.ANIMALS);

		videoToUpload.setKeyWords(keyWordsTestList);
		videoToUpload.setCategories(categories);
		videoToUpload.setPublicationState(State.PUBLIC);
		videoToUpload.setTitle("test video title");
		videoToUpload.setDescription("test video description ");

		String videoPath = "C:\\Cristina\\freezing-fart.avi";

		youtube.insertVideo(user, videoToUpload, videoPath);
	}

	@Test
	public void test_PU_24() {
		/*
		 * YouTubeVideo getVideo(String urlVideo)
		 */
		try {
			youtube.getVideo(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_25() {
		/*
		 * YouTubeVideo getVideo(String urlVideo)
		 */
		try {
			youtube.getVideo("");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_26() throws SecurityException, YouTubeException {
		/*
		 * YouTubeVideo getVideo(String urlVideo)
		 */
		YouTubeVideo video = youtube.getVideo("17_SS4T-z6A");
		assertNotNull(video);
	}

	@Test
	public void test_PU_27() throws SecurityException, YouTubeException {
		/*
		 * StandarVideos getStandarVideos()
		 */
		StandarVideos videos = youtube.getStandarVideos();
		assertNotNull(videos);
	}

	@Test
	public void test_PU_28() {
		/*
		 * StandarVideos getStandarVideos(Integer indexStart, Integer
		 * maxResults)
		 */
		try {
			youtube.getStandarVideos(null, 2);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_29() {
		/*
		 * StandarVideos getStandarVideos(Integer indexStart, Integer
		 * maxResults)
		 */
		try {
			youtube.getStandarVideos(2, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_30() throws SecurityException, YouTubeException {
		/*
		 * StandarVideos getStandarVideos(Integer indexStart, Integer
		 * maxResults)
		 */
		StandarVideos videos = youtube.getStandarVideos(2, 2);
		assertNotNull(videos);
	}

	@Test
	public void test_PU_31() throws SecurityException, YouTubeException {
		/*
		 * getContacts(YouTubeUser user)
		 */
		try {
			youtube.getContacts(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_32() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getContacts(YouTubeUser user)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		List<YouTubeContact> contactList = youtube.getContacts(user);
		assertNotNull(contactList);
		assertEquals(0, contactList.size());
	}

	@Test
	public void test_PU_33() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addContact(YouTubeUser user, String userName)
		 */
		try {
			String name = "contactName";
			youtube.addContact(null, name);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_34() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addContact(YouTubeUser user, String userName)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		try {
			youtube.addContact(user, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_35() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addContact(YouTubeUser user, String userName)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		try {
			youtube.addContact(user, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_36() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * addContact(YouTubeUser user, String userName)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);
		String name = "drakodga";
		youtube.addContact(user, name);

		List<YouTubeContact> contactList = youtube.getContacts(user);
		assertNotNull(contactList);
		assertTrue(contactList.size()>0);
	}

	@Test
	public void test_PU_37() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteContact(YouTubeUser user, String userName)
		 */
		try {
			String name = "drakodga";
			youtube.deleteContact(null, name);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_38() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteContact(YouTubeUser user, String userName)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		try {
			youtube.deleteContact(user, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_39() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteContact(YouTubeUser user, String userName)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		try {
			youtube.deleteContact(user, "");
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_40() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * deleteContact(YouTubeUser user, String userName)
		 */

		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);
		String name = "drakodga";
		youtube.addContact(user, name);

		List<YouTubeContact> contactList = youtube.getContacts(user);
		assertNotNull(contactList);
		int numContacts = contactList.size();
		assertTrue(numContacts>0);

		youtube.deleteContact(user, name);
		contactList = youtube.getContacts(user);
		assertNotNull(contactList);
		assertEquals(numContacts-1, contactList.size());
	}

	@Test
	public void test_PU_41() {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		try {
			youtube.search(null, OrderBy.VIEW_COUNT, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_42() {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		try {
			youtube.search(YouTubeType.ALL, null, keywords);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_43() {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		try {
			youtube.search(YouTubeType.ALL, OrderBy.VIEW_COUNT, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_44() throws SecurityException, YouTubeException {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		YouTubeResult result = youtube.search(YouTubeType.ALL,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.getPlayLists().size() != 0);
		assertTrue(result.getVideos().size() != 0);
	}

	@Test
	public void test_PU_45() throws SecurityException, YouTubeException {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		YouTubeResult result = youtube.search(YouTubeType.PLAYLIST,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.getPlayLists().size() != 0);
		assertTrue(result.getVideos().size() == 0);
	}

	@Test
	public void test_PU_46() throws SecurityException, YouTubeException {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		YouTubeResult result = youtube.search(YouTubeType.VIDEO,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.getPlayLists().size() == 0);
		assertTrue(result.getVideos().size() != 0);
	}

	@Test
	public void test_PU_47() throws SecurityException, YouTubeException {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		YouTubeResult result = youtube.search(YouTubeType.ALL,
				OrderBy.RELEVANCE, keywords);
		assertNotNull(result);
		assertTrue(result.getPlayLists().size() != 0);
		assertTrue(result.getVideos().size() != 0);
	}

	@Test
	public void test_PU_48() throws SecurityException, YouTubeException {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		YouTubeResult result = youtube.search(YouTubeType.ALL, OrderBy.RATING,
				keywords);
		assertNotNull(result);
		assertTrue(result.getPlayLists().size() != 0);
		assertTrue(result.getVideos().size() != 0);
	}

	@Test
	public void test_PU_49() throws SecurityException, YouTubeException {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		YouTubeResult result = youtube.search(YouTubeType.ALL,
				OrderBy.PUBLISHED, keywords);
		assertNotNull(result);
		assertTrue(result.getPlayLists().size() != 0);
		assertTrue(result.getVideos().size() != 0);
	}

	@Test
	public void test_PU_50() {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		try {
			youtube.explore(null, OrderBy.VIEW_COUNT, null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_51() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("dog");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.ANIMALS,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_52() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("ferrari");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.AUTOS,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_53() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("movie");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.COMEDY,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_54() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("computers");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.EDUCATION,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_55() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("movie");
		List<YouTubeVideoMinimal> result = youtube.explore(
				Category.ENTERTAINMENT, OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_56() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("comedy");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.FILM,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_57() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("nintendo");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.GAMES,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_58() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("word");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.HOWTO,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_59() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String> keywords)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("comedy");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.MOVIES,
				OrderBy.VIEW_COUNT, keywords);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_60() throws SecurityException, YouTubeException {
		/*
		 * search(YouTubeType type, OrderBy order,List<String> keywords,Integer
		 * indexStart, Integer maxResults)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		YouTubeResult result = youtube.search(YouTubeType.ALL,
				OrderBy.VIEW_COUNT, keywords, 2, 2);
		assertNotNull(result);
		assertTrue(result.getPlayLists().size() != 0);
		assertTrue(result.getVideos().size() != 0);
	}

	@Test
	public void test_PU_61() throws SecurityException, YouTubeException {
		/*
		 * explore(Category category, OrderBy order, List<String>
		 * keywordsInteger indexStart, Integer maxResults)
		 */
		List<String> keywords = new ArrayList<String>();
		keywords.add("dog");
		List<YouTubeVideoMinimal> result = youtube.explore(Category.ANIMALS,
				OrderBy.VIEW_COUNT, keywords, 2, 2);
		assertNotNull(result);
		assertTrue(result.size() != 0);
	}

	@Test
	public void test_PU_62() throws SecurityException, YouTubeException {
		/*
		 * getUserVideos(YouTubeUser user)
		 */
		try {
			youtube.getUserVideos(null);
			fail();
		} catch (Exception e) {
		}
	}

	@Test
	public void test_PU_63() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getUserVideos(YouTubeUser user)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		// test for uploading a video
		YouTubeVideo videoToUpload = new YouTubeVideo();

		List<String> keyWordsTestList = new ArrayList<String>();
		keyWordsTestList.add("tortuga");
		keyWordsTestList.add("mascota");
		keyWordsTestList.add("animal");

		List<Category> categories = new ArrayList<Category>();
		categories.add(Category.ANIMALS);

		videoToUpload.setKeyWords(keyWordsTestList);
		videoToUpload.setCategories(categories);
		videoToUpload.setPublicationState(State.PUBLIC);
		videoToUpload.setTitle("test video title");
		videoToUpload.setDescription("test video description ");

		String videoPath = "C:\\Cristina\\freezing-fart.avi";

		youtube.insertVideo(user, videoToUpload, videoPath);

		List<YouTubeVideoMinimal> videos = youtube.getUserVideos(user);
		assertNotNull(videos);
		assertTrue(videos.size()>0);
		
		boolean found = false;
		for (int i = 0; i < videos.size(); i++) {
			YouTubeVideoMinimal entry = videos.get(i);
			if (entry.getTitle().equals("test video title")) {
				found = true;
			}
		}
		assertTrue(found);
	}

	@Test
	public void test_PU_64() throws SecurityException, YouTubeException,
			YouTubeAuthException {
		/*
		 * getUserVideos(YouTubeUser user)
		 */
		int userId = 1;
		String youtubeName = "you2bectc";
		String youtubePass = "citiccitic";
		youtube.registreUser(userId, youtubeName, youtubePass);

		// getting user profile
		YouTubeUser user = youtube.getUserProfile(userId);

		// test for uploading a video
		YouTubeVideo videoToUpload = new YouTubeVideo();

		List<String> keyWordsTestList = new ArrayList<String>();
		keyWordsTestList.add("tortuga");
		keyWordsTestList.add("mascota");
		keyWordsTestList.add("animal");

		List<Category> categories = new ArrayList<Category>();
		categories.add(Category.ANIMALS);

		videoToUpload.setKeyWords(keyWordsTestList);
		videoToUpload.setCategories(categories);
		videoToUpload.setPublicationState(State.PUBLIC);
		videoToUpload.setTitle("test video title");
		videoToUpload.setDescription("test video description ");

		String videoPath = "C:\\Cristina\\freezing-fart.avi";

		youtube.insertVideo(user, videoToUpload, videoPath);

		List<YouTubeVideoMinimal> videos = youtube.getUserVideos(user,1,2);
		assertNotNull(videos);
		assertTrue(videos.size()>0);
		
		boolean found = false;
		for (int i = 0; i < videos.size(); i++) {
			YouTubeVideoMinimal entry = videos.get(i);
			if (entry.getTitle().equals("test video title")) {
				found = true;
			}
		}
		assertTrue(found);				
	}
}
